package top.humbleyuan.test;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @Author HumbleYuan
 * @Date 2020/3/28 18:52
 * @Des
 */
public class QIExamDemo {
    public static void main(String[] args) {
        //Q1();

        int[] num = new int[10];
        int[] result = new int[9];
        for (int i = 0; i < num.length; i++)
        {
            num[i] = i + 1;
        }
        for (int x = 0, k = num.length; x < result.length; x++, k--)
        {
            int r = (int) (Math.random() * k);
            result[x] = num[r];
            num[r] = num[k - 1];
            //num.length--; //这句话是错误的,可以定义一个变量k、其值为数组的长度,每次k--就ok了
        }
        Arrays.sort(result);
        for (int y = 0; y < result.length; y++)
        {
            System.out.println(result[y]);
        }


        // 三角数独
        // sudoku();
    }

    private static void sudoku() {
        Scanner sc = new Scanner(System.in);

        while (sc.hasNext()) {
            int[] nums = new int[9];
            for (int i = 0; i < nums.length; i++) {
                nums[i] = sc.nextInt();
            }

            int sum = 0;
            for (int i = 0; i < nums.length; i++) {
                sum += nums[i];
            }

            // (9个取三个 + sum) % 3 = 0

            for (int i = 0; i < nums.length; i++) {
                for (int j = i; j < nums.length; j++) {
                    for (int k = j; k < nums.length; k++) {
                        if(sum + nums[i] + nums[j] + nums[k] % 3 == 0) {

                        }
                    }
                }
            }
        }
        sc.close();
    }

    private static void Q1() {
        Scanner sc = new Scanner(System.in);

        while (sc.hasNext()) {
           int m = sc.nextInt();
           if(m < 3) {
               System.out.println(5);
           } else if(m < 5){
               System.out.println(8);
           } else if(m < 7) {
               System.out.println(11);
           } else if(m < 12) {
               System.out.println(13);
           } else if(m < 15) {
               System.out.println(17);
           }
        }

        sc.close();
    }
}
